/**
 * Created by zhulizhe on 2017/9/7.
 */
export default class NumberUtil {
    static getRandomNum(Min, Max) {
        var Range = Max - Min;
        var Rand = Math.random();
        return (Min + Math.round(Rand * Range));
    }
    static phoneNumFormat(number){
        if(number.length > 13)return number.substring(0,12);
        let numberStr = number + '' ;
        numberStr = numberStr.replace('-','') ;
        const reg = /(^\d{3}|\d{4}\B)/g ;
        let finalStr =  numberStr.replace(reg,"$1-");
        return finalStr.substring(0,finalStr.length) ;
    }
    //价格格式化保留count 位
    static priceFormat(number,count=2){
        return number.toFixed(count) ;
    }
    // 去除手机号码修饰字符
    static removeDecoratePhoneNumber(phone){
        var pattern = /-/g;
        return phone.replace(new RegExp(pattern), "");
    }
}